package com.hackerrank.www.javap.Strings;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Created by 27340 on 2017/5/21.
 */
public class Anagrams {
    public static void proMap(String str, HashMap<Character,Integer> map){
        for(int index=0;index<str.length();index++){
            Character key = str.charAt(index);
            if(map.get(key)==null){
                map.put(key,1);
            }else {
                map.put(key,map.get(key)+1);
            }
        }
    }
    public static boolean isAnagram(String str1, String str2){
        HashMap<Character,Integer> map1 = new HashMap<Character,Integer>();
        HashMap<Character,Integer> map2 = new HashMap<Character,Integer>();
        proMap(str1.toLowerCase(),map1);
        proMap(str2.toLowerCase(),map2);
        return map1.equals(map2);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        String b = scan.next();
        scan.close();
        boolean ret = isAnagram(a, b);
        System.out.println( (ret) ? "Anagrams" : "Not Anagrams" );
    }
}
